<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title th:text="${document.title} + ' - 文档管理系统'">文档标题 - 文档管理系统</title>
    <link rel="stylesheet" href="/css/style.css">
    <style>
        /* 背景图片样式 */
        body {
            position: relative;
            background-color: #2d2d2d;
        }
        
        body::before {
            content: '';
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: -2;
            background-image: var(--bg-image);
            background-position: center;
            background-size: cover;
            background-repeat: no-repeat;
        }
        
        body::after {
            content: '';
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: -1;
            background-color: rgba(0, 0, 0, var(--bg-opacity, 0.3));
        }
        
        /* 文档分类标签样式 */
        .document-category {
            display: inline-block;
            padding: 5px 10px;
            background: rgba(0, 100, 200, 0.3);
            color: rgba(240, 250, 255, 0.95);
            border-radius: 4px;
            font-size: 14px;
            margin-right: 10px;
            border: none;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
        }
        
        .document-meta {
            display: flex;
            align-items: center;
            margin-bottom: 20px;
            color: rgba(240, 250, 255, 0.95);
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
        }
        
        .meta-item {
            margin-right: 15px;
            color: rgba(240, 250, 255, 0.95);
        }
        
        /* 文档内容区域 */
        .document-detail {
            background: transparent;
            border-radius: 10px;
            padding: 20px;
            margin-bottom: 20px;
            border: none;
        }
        
        .document-header h1 {
            color: rgba(240, 250, 255, 0.98);
            text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), 0 0 8px rgba(0, 120, 255, 0.6);
        }
        
        .document-content {
            color: rgba(240, 250, 255, 0.95);
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
            line-height: 1.6;
        }
        
        /* 相关文档样式 */
        .related-documents {
            margin-top: 40px;
            padding-top: 20px;
            border-top: 1px solid rgba(255, 255, 255, 0.1);
        }
        
        .related-documents h3 {
            margin-bottom: 15px;
            color: rgba(240, 250, 255, 0.95);
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
        }
        
        .related-list {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 15px;
        }
        
        .related-item {
            padding: 15px;
            background: rgba(0, 0, 0, 0.2);
            border-radius: 8px;
            border: none;
        }
        
        .related-item h4 {
            margin-top: 0;
            margin-bottom: 10px;
            color: rgba(240, 250, 255, 0.95);
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
        }
        
        .related-item a {
            color: rgba(220, 240, 255, 0.95);
            text-decoration: none;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
        }
        
        .related-item a:hover {
            text-decoration: underline;
        }
        
        /* 文档图片样式 */
        .document-image {
            width: 100%;
            height: auto;
            max-height: 400px;
            object-fit: cover;
            border-radius: 8px;
            margin: 20px 0;
            border: 1px solid rgba(255, 255, 255, 0.2);
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
        }
        
        /* 按钮样式 */
        .btn {
            background: rgba(0, 0, 0, 0.2);
            border: none;
            color: rgba(240, 250, 255, 0.95);
            padding: 6px 12px;
            border-radius: 20px;
            font-size: 14px;
            cursor: pointer;
            transition: all 0.3s;
            outline: none;
            text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
            text-decoration: none;
            display: inline-block;
            margin-right: 10px;
        }
        
        .btn:hover {
            background: rgba(0, 0, 0, 0.3);
        }
        
        /* 内容控制按钮样式 */
        .content-controls {
            margin: 15px 0;
        }
        
        .btn-control {
            background: rgba(0, 100, 200, 0.2);
            font-size: 13px;
            padding: 5px 15px;
        }
        
        .btn-control:hover {
            background: rgba(0, 100, 200, 0.3);
        }
        
        /* 内容样式 */
        .content-text {
            background: rgba(0, 0, 0, 0.15);
            padding: 15px;
            border-radius: 8px;
            position: relative;
        }
        
        /* 渐变隐藏效果 */
        .content-text::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 50px;
            background: linear-gradient(transparent, rgba(0, 0, 0, 0.2));
            pointer-events: none;
            opacity: var(--gradient-opacity, 1);
            transition: opacity 0.3s;
            border-bottom-left-radius: 8px;
            border-bottom-right-radius: 8px;
        }
        
        /* 页眉和页脚透明化 */
        .main-header, .main-footer {
            background: transparent;
            backdrop-filter: none;
            -webkit-backdrop-filter: none;
            border: none;
        }
        
        .main-header h1 {
            color: rgba(240, 250, 255, 0.98);
            text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
        }
        
        .main-header nav ul {
            display: flex;
            list-style: none;
            padding: 0;
        }
        
        .main-header nav ul li {
            margin-right: 15px;
        }
        
        .main-header nav ul li a {
            color: rgba(240, 250, 255, 0.95);
            text-decoration: none;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
        }
        
        .main-footer p {
            color: rgba(240, 250, 255, 0.95);
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
        }
    </style>
</head>
<body th:style="${backgroundImage != '' ? '--bg-image: url(' + backgroundImage + '); --bg-opacity: ' + backgroundOpacity : '--bg-opacity: ' + backgroundOpacity}">
    <header class="main-header">
        <div class="container">
            <nav>
                <ul>
                    <li><a href="/">主页</a></li>
                    <li><a href="/weblinks">网站导航</a></li>
                    <li><a href="/danmaku-display">弹幕墙</a></li>
                    <li><a href="/login" th:if="${#authorization.expression('!isAuthenticated()')}">登录</a></li>
                    <li><a href="/register" th:if="${#authorization.expression('!isAuthenticated()')}">注册</a></li>
                    <li><a href="/dashboard" th:if="${#authorization.expression('isAuthenticated()')}">个人中心</a></li>
                    <li><a href="/logout" th:if="${#authorization.expression('isAuthenticated()')}">退出</a></li>
                </ul>
            </nav>
        </div>
    </header>

    <main class="container">
        <article class="document-detail">
            <div class="document-header">
                <h1 th:text="${document.title}">文档标题</h1>
                <div class="document-meta">
                    <div th:if="${document.category != null}" class="document-category" th:text="${document.category.name}">文档分类</div>
                    <div class="meta-item">发布时间：<span th:text="${#temporals.format(document.createdAt, 'yyyy-MM-dd HH:mm')}">2025-03-13 16:30</span></div>
                    <div class="meta-item">作者：<span th:text="${document.author}">作者</span></div>
                </div>
            </div>
            
            <div class="document-content">
                <!-- 使用th:utext和pre-wrap样式保留格式 -->
                <div class="content-text" th:utext="${#strings.replace(#strings.escapeXml(document.content),'&#10;','<br>')}" style="white-space: pre-wrap; margin-bottom: 20px;">文档内容...</div>
                
                <!-- 添加折叠/展开功能 -->
                <div class="content-controls">
                    <button id="expandBtn" class="btn btn-control">展开全部</button>
                    <button id="collapseBtn" class="btn btn-control">收起内容</button>
                </div>
                
                <img th:if="${document.imagePath != null}" th:src="${document.imagePath}" alt="文档图片" class="document-image">
            </div>
            
            <div class="document-actions">
                <a href="/" class="btn btn-secondary">返回首页</a>
                <a th:if="${document.category != null}" th:href="@{/(categoryId=${document.category.id})}" class="btn btn-info">查看同分类文档</a>
            </div>
        </article>
    </main>

    <footer class="main-footer">
        <div class="container">
            <p>&copy; 2025 文档管理系统. 保留所有权利.</p>
        </div>
    </footer>

    <script src="/js/script.js"></script>
    <script th:inline="javascript">
        document.addEventListener('DOMContentLoaded', function() {
            const contentText = document.querySelector('.content-text');
            const expandBtn = document.getElementById('expandBtn');
            const collapseBtn = document.getElementById('collapseBtn');
            
            // 初始状态设置最大高度
            let isCollapsed = true;
            const maxHeight = '300px';
            contentText.style.maxHeight = maxHeight;
            contentText.style.overflow = 'hidden';
            contentText.style.transition = 'max-height 0.3s ease';
            
            // 展开按钮点击事件
            expandBtn.addEventListener('click', function() {
                if (isCollapsed) {
                    contentText.style.maxHeight = '10000px'; // 设置一个很大的值
                    contentText.style.setProperty('--gradient-opacity', '0'); // 隐藏渐变
                    isCollapsed = false;
                    expandBtn.style.display = 'none';
                    collapseBtn.style.display = 'inline-block';
                }
            });
            
            // 收起按钮点击事件
            collapseBtn.addEventListener('click', function() {
                if (!isCollapsed) {
                    contentText.style.maxHeight = maxHeight;
                    contentText.style.setProperty('--gradient-opacity', '1'); // 显示渐变
                    isCollapsed = true;
                    expandBtn.style.display = 'inline-block';
                    collapseBtn.style.display = 'none';
                }
            });
            
            // 初始隐藏收起按钮
            collapseBtn.style.display = 'none';
            
            // 设置CSS变量
            document.documentElement.style.setProperty('--gradient-opacity', '1');
        });
    </script>
</body>
</html> 